home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c++
- Subject: Re: Memory deallocation in C and C++
- Date: Sat, 13 Jan 1996 13:54:45 GMT
- Organization: Netcom
- Message-ID: <30f7b91d.67934144@nntp.ix.netcom.com>
- References: <4d7r6p$dvg@newsbf02.news.aol.com>
- NNTP-Posting-Host: ix-dc11-30.ix.netcom.com
- X-NETCOM-Date: Sat Jan 13 5:54:29 AM PST 1996
- X-Newsreader: Forte Agent .99c/16.141
-
- weatby@aol.com (Weatby) wrote:
-
- |>delete() and free() can cause problems on at least some compilers if
- |>called with an invalid pointer.
- |>
- |>It would seem to me that a better idea would be that if the pointer
- passed
- |>hasn't been allocated by the memory management system, it could just
- be
- |>ignored, instead of causing a crash as does on my compiler.
- |>
- |>Or, a return value could be added to indicate a bad status.
- |>
- |>Any comments/ideas on why these are not done?
-
- Cost. On many (most?) systems it would be very expensive to check if
- a pointer had been allocated dynamically. If the pointer is an auto
- variable it is impossible since the pointer could take on any value,
- including one that happened to match that of a dynamically allocated
- pointer.
-
-
- Michael M Rubenstein
-